package org.jeecg.modules.htxincailiao.goods.entity;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.util.oConvertUtils;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: ht_goods
 * @Author: jeecg-boot
 * @Date: 2022-07-13 10:51:36
 * @Version: V1.0
 */
@Data
@TableName("ht_goods")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "ht_goods对象", description = "ht_goods")
public class HTGoods implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键ID")
    private String id;
    /**
     * 分类ID
     */
    @Excel(name = "分类ID", width = 15, dictTable = "ht_goods_category", dicText = "name", dicCode = "id")
    @Dict(dictTable = "ht_goods_category", dicText = "name", dicCode = "id")
    @ApiModelProperty(value = "分类ID")
    private String categoryId;

    @TableField(exist = false)
    private String categoryName;
    /**
     * 企业
     */
    @Excel(name = "企业", width = 15, dictTable = "ht_merchant", dicText = "enterprise_name", dicCode = "id")
    @Dict(dictTable = "ht_merchant", dicText = "enterprise_name", dicCode = "id")
    @ApiModelProperty(value = "企业")
    private String shopId;
    /**
     * 排序
     */
    @Excel(name = "排序", width = 15)
    @ApiModelProperty(value = "排序")
    private Integer sort;
    /**
     * 首页排序
     */
    @Excel(name = "首页排序", width = 15)
    @ApiModelProperty(value = "首页排序")
    private Integer homeSort;
    /**
     * SKU
     */
    @Excel(name = "SKU", width = 15)
    @ApiModelProperty(value = "SKU")
    private String sku;
    /**
     * 标题
     */
    @Excel(name = "标题", width = 15)
    @ApiModelProperty(value = "标题")
    private String name;
    /**
     * 副标题
     */
    @Excel(name = "副标题", width = 15)
    @ApiModelProperty(value = "副标题")
    private String subname;
    /**
     * 关键字
     */
    @Excel(name = "关键字", width = 15)
    @ApiModelProperty(value = "关键字")
    private String keywords;

    /**
     * 视频
     */
    @Excel(name = "视频", width = 15)
    @ApiModelProperty(value = "视频")
    private String videoUrls;

    /**
     * 主图
     */
    @Excel(name = "主图", width = 15)
    @ApiModelProperty(value = "主图")
    private String cover;
    /**
     * 图片集
     */
    @Excel(name = "图片集", width = 15)
    @ApiModelProperty(value = "图片集")
    private String images;

    /**预览文件（.pdf）*/
    @Excel(name = "产品说明书（.pdf）", width = 15)
    @ApiModelProperty(value = "产品说明书（.pdf）")
    private String pdfGuide;

    /**
     * 详细内容
     */
    @Excel(name = "详细内容", width = 15)
    @ApiModelProperty(value = "详细内容")
    private String content;

    /**
     * 规格参数
     */
    @Excel(name = "规格参数", width = 15)
    @ApiModelProperty(value = "规格参数")
    private String attributes;

    /**
     * 详细内容
     */
    @Excel(name = "售后服务", width = 15)
    @ApiModelProperty(value = "售后服务")
    private String afterSaleService;

    /**
     * 成本价
     */
    @Excel(name = "成本价", width = 15)
    @ApiModelProperty(value = "成本价")
    private BigDecimal costPrice;
    /**
     * 市场价（实际销售价格）
     */
    @Excel(name = "市场价（实际销售价格）", width = 15)
    @ApiModelProperty(value = "市场价（实际销售价格）")
    private BigDecimal marketPrice;
    /**
     * 零售价（厂家定价）
     */
    @Excel(name = "零售价（厂家定价）", width = 15)
    @ApiModelProperty(value = "零售价（厂家定价）")
    private BigDecimal retailPrice;
    /**
     * 售出数量
     */
    @Excel(name = "售出数量", width = 15)
    @ApiModelProperty(value = "售出数量")
    private Integer saleAmount;
    /**
     * 库存数量
     */
    @Excel(name = "库存数量", width = 15)
    @ApiModelProperty(value = "库存数量")
    private Integer stockAmount;
    /**
     * 库存单元ID
     */
    @Excel(name = "库存单元ID", width = 15)
    @ApiModelProperty(value = "库存单元ID")
    private String unitId;
    /**
     * 产地
     */
    @Excel(name = "产地", width = 15)
    @ApiModelProperty(value = "产地")
    private String placeOrigin;
    /**
     * 是否为首页推荐 0-不推荐 1-推荐)
     */
    @Excel(name = "是否为首页推荐 0-不推荐 1-推荐)", width = 15, dicCode = "is_home_recommended")
    @Dict(dicCode = "is_home_recommended")
    @ApiModelProperty(value = "是否为首页推荐 0-不推荐 1-推荐)")
    private Integer isHomeRecommended;
    /**
     * 是否为企业首页推荐 0-不推荐 1-推荐
     */
    @Excel(name = "是否为企业首页推荐 0-不推荐 1-推荐", width = 15, dicCode = "is_enterprise_home_recommended")
    @Dict(dicCode = "is_enterprise_home_recommended")
    @ApiModelProperty(value = "是否为企业首页推荐 0-不推荐 1-推荐")
    private String isEnterpriseHomeRecommended;
    /**
     * 商品状态（状态 0-未上架,1-上架,2-下架）
     */
    @Excel(name = "商品状态（状态 0-未上架,1-上架,2-下架）", width = 15, dicCode = "goods_status")
    @Dict(dicCode = "goods_status")
    @ApiModelProperty(value = "商品状态（状态 0-未上架,1-上架,2-下架）")
    private String goodsStatus;
    /**
     * 审批人
     */
    @Excel(name = "审批人", width = 15)
    @ApiModelProperty(value = "审批人")
    private String auditUsername;
    /**
     * 审核状态：0-未审核 1-审核中 2-已通过 3-已驳回
     */
    @Excel(name = "审核状态：0-未审核 1-审核中 2-已通过 3-已驳回", width = 15, dicCode = "audit_status")
    @Dict(dicCode = "audit_status")
    @ApiModelProperty(value = "审核状态：0-未审核 1-审核中 2-已通过 3-已驳回")
    private String auditStatus;
    /**
     * 审批意见
     */
    @Excel(name = "审批意见", width = 15)
    @ApiModelProperty(value = "审批意见")
    private String auditComments;
    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**
     * 创建时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    /**
     * 更新人
     */
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    /**
     * 更新时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    /**SEO关键字*/
    @Excel(name = "SEO关键字", width = 15)
    @ApiModelProperty(value = "SEO关键字")
    private String seoKeywords;


    /**SEO描述*/
    @Excel(name = "SEO描述", width = 15)
    @ApiModelProperty(value = "SEO描述")
    private String seoDescription;

    @Excel(name = "商品描述", width = 15)
    @ApiModelProperty(value = "商品描述")
    private String description;

    @TableField(exist = false)
    private Integer pageNo;

    @TableField(exist = false)
    private Integer pageSize;

    @TableField(exist = false)
    private String[] imageList;

    public String[] getImageList() {
        String[] empty = new String[]{};

        if (oConvertUtils.isEmpty(images)) {
            return new String[]{cover};
        } else {
            List<String> combineList = new ArrayList<>();
            combineList.add(cover);

            String[] imageItems = images.split(",");
            List<String> imageList = Arrays.asList(imageItems);
            if (oConvertUtils.isNotEmpty(imageList) && !imageList.isEmpty()) {
                combineList.addAll(imageList);
            }

            return combineList.toArray(new String[0]);
        }
    }

    @TableField(exist = false)
    private String[] videoList;

    public String[] getVideoList() {
        String[] empty = new String[]{};

        if (oConvertUtils.isNotEmpty(videoUrls)) {
            String[] videoItems = videoUrls.split(",");

            List<String> list = Arrays.asList(videoItems);

            return list.toArray(new String[0]);
        }

        return empty;
    }

    @TableField(exist = false)
    private String[] mediaList;

    public String[] getMediaList() {
        List<String> list = new ArrayList<>();

        if (oConvertUtils.isNotEmpty(videoUrls)) {
            String[] videoItems = videoUrls.split(",");
            if (oConvertUtils.isNotEmpty(videoItems)) {
                list.addAll(Arrays.asList(videoItems));
            }
        } else {
            list.add(cover);
        }

        if (oConvertUtils.isNotEmpty(images)) {
            String[] imageItems = images.split(",");
            List<String> imageList = Arrays.asList(imageItems);
            if (oConvertUtils.isNotEmpty(imageList) && !imageList.isEmpty()) {
                list.addAll(imageList);
            }
        }

        return list.toArray(new String[0]);
    }


    @TableField(exist = false)
    private String poster;

    public String getPoster() {
        return cover;
    }
}
